﻿@{
    ViewBag.Title = "CorpInfo";
}

@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script> 
}

<form id="form1" method="post">
            @Html.Partial("~/Views/Modular/Toolbars.cshtml")
    <div id="tabs1" class="mini-tabs" activeIndex="0"  style="width:100%; height:100%; top: 0px; left: 0px;overflow:hidden;border:none;" plain="true"  
        buttons="#tabsButtons">
        <div name="Base" title="商户资料" style="height:100%;overflow:hidden;margin-top:15px;margin-left:20px">
            <table style="margin-left:20px">
                <tr>
                    <td width="80px" height="35px" align="right">商户编码：
                    </td>
                    <td width="200px" height="35px">
                        <input name="FNumber" id="FNumber" class="mini-textbox" style="width:200px;" enabled="false" value="" TabIndex="1" />
                    </td>
                    <td width="80px" height="35px" align="right">会员签到积分：
                    </td>
                    <td width="200px" height="35px">
                        <input name="FIntForLogin" id="FIntForLogin" class="mini-textbox" style="width:200px;" value="0" TabIndex="7" />
                    </td>
                </tr>
                <tr>
                    <td width="80px" height="35px" align="right">
                        商户名称：
                    </td>
                    <td width="200px" height="35px">
                        <input id="FName" name="FName" class="mini-textbox " style="width:200px;" TabIndex="2" />
                    </td>
                    <td width="80px" height="35px" align="right">
                        电话号码：
                    </td>
                    <td width="200px" height="35px">
                        <input name="FTelephone" id="FTelephone" class="mini-textbox" style="width:200px;" value="" TabIndex="8" />
                    </td>
                </tr>
                <tr>
                    <td width="80px" height="35px" align="right">
                        联系人：
                    </td>
                    <td width="200px" height="35px">
                        <input id="FManager" name="FManager" class="mini-textbox " style="width:200px;" TabIndex="3" />
                    </td>
                    <td width="80px" height="35px" align="right">
                        电子邮箱：
                    </td>
                    <td width="200px" height="35px">
                        <input name="FEMail" id="FEMail" class="mini-textbox" style="width:200px;" value="" TabIndex="9" />
                    </td>
                </tr>
                <tr>
                    <td width="80px" height="35px" align="right">
                        联系地址：
                    </td>
                    <td width="200px" height="35px">
                        <input id="FAddress" name="FAddress" class="mini-textbox " style="width:200px;" TabIndex="4" />
                    </td>
                    <td width="80px" height="35px" align="right">
                        表头名称：
                    </td>
                    <td width="200px" height="35px">
                        <input name="FBillPrtName" id="FBillPrtName" class="mini-textbox" style="width:200px;" value="" TabIndex="10" />
                    </td>
                </tr>
                <tr>
                    <td width="80px" height="35px" align="right">
                        客户名称：
                    </td>
                    <td width="200px" height="35px">
                        <input id="FCustName" name="FCustName" class="mini-textbox " style="width:200px;" TabIndex="5" />
                    </td>
                    <td width="80px" height="35px" align="right">
                        备注：
                    </td>
                    <td width="200px" height="35px">
                        <input name="FRemark" id="FRemark" class="mini-textbox" style="width:200px;" value="" TabIndex="11" />
                    </td>
                </tr>
                <tr>
                    <td width="80px" height="35px" align="right">第三方电商：</td>
                    <td width="200px" height="35px">
                        <input id="FMallShopID" name="FMallShopID" class="mini-combobox" style="width:200px;" showNullItem="false"
                               allowInput="false" align="left" value="0" data="dMallShopID" tabindex="13" />
                    </td>
                    <td width="80px" height="35px" align="right">接入商户ID：</td>
                    <td width="200px" height="35px">
                        <input id="FMallShopNo" name="FMallShopNo" class="mini-textbox " style="width:200px;" maxlength="30" TabIndex="6" />
                    </td>                    
                </tr>
                <tr>
                    <td width="80px" height="35px" align="right">分店类型：</td>
                    <td width="200px" height="35px">
                        <input id="FShopType" name="FShopType" class="mini-combobox" style="width:200px;" showNullItem="false"
                               allowInput="false" align="left" value="0" data="dShopType" tabindex="13" />
                    </td>
                    <td width="80px" height="35px" align="right"></td>
                    <td width="200px" height="35px">
                    </td>                    
                </tr>
            </table>
        </div>
        <div name="otherset" title="表格设置" style="height:100%;overflow:hidden;margin-top:15px;margin-left:20px">
            <table style="width:100%;">
                <tr>
                    <td colspan="6">
                        选择要隐藏的数据
                    </td>
                </tr>
                <tr>
                    <td style="width:3%;"></td>
                    <td style="width:20%;">
                        <div id="FPurPriceFlag" name="FPurPriceFlag" class="mini-checkbox" style="margin-right: 0px" readOnly="false" 
                            checked="false" text="进货价"></div>
                    </td>
                    <td style="width:20%;">
                        <div id="FRmoPriceFlag" name="FRmoPriceFlag" class="mini-checkbox" style="margin-right: 0px" readOnly="false" 
                            checked="false" text="配送价"></div>
                    </td>
                    <td style="width:20%;">&nbsp;
                        <div id="FSalePriceFlag" name="FSalePriceFlag" class="mini-checkbox" style="margin-right: 0px" readOnly="false" 
                            checked="false" text="批发价"></div>
                    </td>
                    <td style="width:20%;">&nbsp;
                    </td>
                    <td style="width:20%;">&nbsp;
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <input name="FItemID" class="mini-hidden" />
</form>


<script>
    var comType = [{ "id": "1", "text": "普通版" },
                   { "id": "5", "text": "专业版" },
                   { "id": "4", "text": "连锁版" }]

    var dMallShopID = [{ "id": "0", "text": "不接入第三方电商" },
                   { "id": "1", "text": "接入第三方电商(API接口)" },
                   { "id": "2", "text": "接入第三方电商(数据库接口)" }]

    var dShopType = [{ "id": "0", "text": "不定" },
                   { "id": "1", "text": "直营门店" },
                   { "id": "2", "text": "加盟门店" }]

    function FormShown() {
        mini.parse();
        if (parent.window.SonCorp() == -1) {
            var tabs = mini.get("tabs1");
            var otherset = tabs.getTab("otherset");
            tabs.updateTab(otherset, { visible: false });
        }
    }

    //加载资料
    function SetInfoData(data) {
        if (data.FItemID == 0) {
            NewInfo();
        } else {
            var form = new mini.Form("form1");
            form.setData(data);
            var jsonstr = '[{\"FSystemAppID\":\"' + parent.window.getSystemAppID() + '\",\"FItemID\":' + data.FItemID + '}]';
            $.post("GetCorp", { json: jsonstr }, function (Data) {
                var mdata = mini.decode(Data);
                if (mdata.data.length > 0) {
                    mini.getbyName("FIntForLogin").setValue(mdata.data[0].FIntForLogin);
                    mini.getbyName("FRmoPriceFlag").setValue(mdata.data[0].FRmoPriceFlag);
                    mini.getbyName("FPurPriceFlag").setValue(mdata.data[0].FPurPriceFlag);
                    mini.getbyName("FSalePriceFlag").setValue(mdata.data[0].FSalePriceFlag);
                    mini.getbyName("FMallShopID").setValue(mdata.data[0].FMallShopID);
                    mini.getbyName("FMallShopNo").setValue(mdata.data[0].FMallShopNo);
                    mini.getbyName("FShopType").setValue(mdata.data[0].FShopType);
                }
            });
        }
    }

    function NewInfo() {
        mini.getbyName("FCorpItemID").setText('');
        mini.getbyName("FCorpItemID").setValue('');
        mini.getbyName("FCorpName").setValue('');
        mini.getbyName("FName").setValue('');
        mini.getbyName("FTelephone").setValue('');
        mini.getbyName("FManager").setValue('');
        mini.getbyName("FEmail").setValue('');
        mini.getbyName("FAddress").setValue('');
        mini.getbyName("FBillPrtName").setValue('');
        $.post('NewNumber', { mSystemAppID: parent.window.getSystemAppID() }, function (data) {
            mini.getbyName("FNumber").setValue(data);
            mini.getbyName("FTelephone").setValue(data);
        });
    }

    //保存资料
    function SaveInfo() {
        mini.getbyName("SaveInfo").disable();
        var form = new mini.Form("#form1");
        if (mini.getbyName("FNumber").getValue() == "" || mini.getbyName("FName").getValue() == "") {
            mini.alert("编码和名称不能为空.");
            mini.getbyName("SaveInfo").enable();
            return;
        }
        var data = form.getData(true, false);
        data.FSystemAppID = parent.window.getSystemAppID();
        data.FPurPriceFlag = mini.getbyName("FPurPriceFlag").getValue();
        data.FRmoPriceFlag = mini.getbyName("FRmoPriceFlag").getValue();
        data.FSalePriceFlag = mini.getbyName("FSalePriceFlag").getValue();
        var json = mini.encode(data);
        $.post("saveCompanyInfo", { json: json }, function (data) {
            var ret = mini.decode(data);
            if (ret.status == 1) {
                mini.alert(ret.msg, "信息", CloseWindow);
            }
            else {
                mini.alert("异常:" + ret.error);
            }
            mini.getbyName("SaveInfo").enable();
        });
    }

</script>